package com.hup.utils.commons.exception.parser;

import com.hup.utils.commons.exception.ErrParserRegister;
import com.hup.utils.commons.exception.ExceptionMsgParser;
import org.springframework.core.task.TaskRejectedException;

import java.util.ArrayList;
import java.util.List;

/**
 * 注册时,需要有以下依赖
 * @author hugan
 * @date 2019/9/10
 */
public class SpringMsgParser implements ErrParserRegister {

    @Override
    public List<ExceptionMsgParser> getParsers() {
        ArrayList<ExceptionMsgParser> list = new ArrayList<>();
        list.add(new TaskRejected());
        return list;
    }

    private static class TaskRejected implements ExceptionMsgParser<TaskRejectedException> {
        @Override
        public String getMsg(TaskRejectedException e) {
            return "请等待已有任务执行完后再次操作";
        }
    }
}
